#include "Contact.h"
void Sort()
{
    FILE *fp;
	struct ContactPerson temp;
	int i = 0;
	int j = 0;
	int count = 0;
	fp = fopen("data.txt","rb");
	while(!feof(fp))
	{
		if(fread(&Infor[count], LENGTH, 1, fp) ==1)
		    count++	;		
    }
    fclose(fp);
    fp = fopen("data.txt","rb");
	for(i=0; i<count-1; i++)
	{
		for(j=i+1; j<count; j++)
		{
			if(strcmp(Infor[i].Name, Infor[j].Name) > 0)
			{
				temp = Infor[i];
				Infor[i] = Infor[j];
				Infor[j] = temp;
			}
		}
		fwrite(&Infor[i], LENGTH, 1, fp);
	}
	Display();
	fclose(fp);
}


